package delasell.adressBook.view;

import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class CreationWindow extends JFrame{
	
	
	protected static JPanel mainPanel;
	
	protected static JButton saveButton;
	protected static JButton cancelButton;
	
	protected static JLabel persAdressLabel;
	protected static JLabel compAdressLabel;
	protected static JLabel persPhoneLabel;
	protected static JLabel compPhoneLabel;
	protected static JLabel webLabel;
	protected static JLabel emailLabel;
	
	protected static JTextField nameDisplay;
	protected static JTextField firstNameDisplay;
	protected static JTextField persAdressDisplay;
	protected static JTextField compAdressDisplay;
	protected static JTextField[] persPhoneDisplay;
	protected static JTextField[] compPhoneDisplay;
	protected static JTextField webDisplay;
	protected static JTextField emailDisplay;
	
	public CreationWindow()
	{
		
		mainPanel = new JPanel();
		
		saveButton = new JButton("Save");
		cancelButton = new JButton("Cancel");
		
		persAdressLabel = new JLabel("Personal Adress");
		compAdressLabel = new JLabel("Company Adress");
		persPhoneLabel = new JLabel("Personal Phone");
		compPhoneLabel = new JLabel("Company PHone");
		webLabel = new JLabel("Web Profile");
		emailLabel = new JLabel("Email");
		
		nameDisplay = new JTextField("Name");
		firstNameDisplay = new JTextField("First Name");
		persAdressDisplay = new JTextField("");
		compAdressDisplay = new JTextField("");
		persPhoneDisplay = new JTextField[2];
		persPhoneDisplay[0] = new JTextField("");
		persPhoneDisplay[1] = new JTextField("");
		compPhoneDisplay = new JTextField[2];
		compPhoneDisplay[0] = new JTextField("");
		compPhoneDisplay[1] = new JTextField("");
		webDisplay = new JTextField("");
		emailDisplay = new JTextField("");
		
		
		Dimension dim = new Dimension(100, 20);
		nameDisplay.setPreferredSize(dim);
		firstNameDisplay.setPreferredSize(dim);
		persAdressDisplay.setPreferredSize(dim);
		compAdressDisplay.setPreferredSize(dim);
		persPhoneDisplay[0].setPreferredSize(dim);
		persPhoneDisplay[1].setPreferredSize(dim);
		compPhoneDisplay[0].setPreferredSize(dim);
		compPhoneDisplay[1].setPreferredSize(dim);
		webDisplay.setPreferredSize(dim);
		emailDisplay.setPreferredSize(dim);
		
		
		mainPanel.setLayout(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		
		c.gridx=0;
		c.gridy=0;
		c.gridheight=1;
		c.gridwidth=2;
		//c.ipady=40;
		c.insets = new Insets(10,10,30,30);
		c.anchor=GridBagConstraints.PAGE_START;
		//c.fill = GridBagConstraints.VERTICAL;
		mainPanel.add(nameDisplay, c);
		
		c.gridx=2;
		mainPanel.add(firstNameDisplay,c);
		
		c.gridx=0;
		c.gridy=1;
		c.gridheight=1;
		c.gridwidth=1;
		mainPanel.add(persAdressLabel,c);
		
		c.gridx=1;
		c.gridy=1;
		mainPanel.add(persAdressDisplay,c);
		
		c.gridx=2;
		c.gridy=1;
		mainPanel.add(compAdressLabel,c);
		
		c.gridx=3;
		c.gridy=1;
		mainPanel.add(compAdressDisplay,c);
		
		c.gridx=0;
		c.gridy=2;
		c.gridheight=2;
		mainPanel.add(persPhoneLabel,c);
		
		c.gridx=2;
		c.gridy=2;
		mainPanel.add(compPhoneLabel,c);
		
		c.gridx=1;
		c.gridy=2;
		c.gridheight=1;
		mainPanel.add(persPhoneDisplay[0],c);
		
		c.gridx=1;
		c.gridy=3;
		mainPanel.add(persPhoneDisplay[1],c);
		
		c.gridx=3;
		c.gridy=2;
		mainPanel.add(compPhoneDisplay[0],c);
		
		c.gridx=3;
		c.gridy=3;
		mainPanel.add(compPhoneDisplay[1],c);
		
		c.gridx=0;
		c.gridy=4;
		mainPanel.add(webLabel,c);
		
		c.gridx=2;
		c.gridy=4;
		mainPanel.add(emailLabel,c);
		
		c.gridx=1;
		c.gridy=4;
		mainPanel.add(webDisplay,c);
		
		c.gridx=3;
		c.gridy=4;
		mainPanel.add(emailDisplay,c);
		
		c.gridx=0;
		c.gridy=5;
		c.gridwidth=2;
		mainPanel.add(saveButton,c);
		
		c.gridx=2;
		mainPanel.add(cancelButton,c);
		
		
		setTitle("Adress Book");
	    setSize(600, 400);
	    this.setResizable(false);
	    setLocationRelativeTo(null);
	    setDefaultCloseOperation(HIDE_ON_CLOSE);
	    this.setContentPane(mainPanel);
		
	}

	public static JButton getSaveButton() {
		return saveButton;
	}

	public static JButton getCancelButton() {
		return cancelButton;
	}

	public static JTextField getNameDisplay() {
		return nameDisplay;
	}

	public static JTextField getFirstNameDisplay() {
		return firstNameDisplay;
	}

	public static JTextField getPersAdressDisplay() {
		return persAdressDisplay;
	}

	public static JTextField getCompAdressDisplay() {
		return compAdressDisplay;
	}

	public static JTextField[] getPersPhoneDisplay() {
		return persPhoneDisplay;
	}

	public static JTextField[] getCompPhoneDisplay() {
		return compPhoneDisplay;
	}

	public static JTextField getWebDisplay() {
		return webDisplay;
	}

	public static JTextField getEmailDisplay() {
		return emailDisplay;
	}

}
